package main

import (
	"fmt"
	. "gitee.com/lllgo/opsctl/pkg/cmd"
	_ "gitee.com/lllgo/opsctl/pkg/cmd/ansible"
	_ "gitee.com/lllgo/opsctl/pkg/cmd/kube"
	_ "gitee.com/lllgo/opsctl/pkg/cmd/notify"
	_ "gitee.com/lllgo/opsctl/pkg/cmd/tasks"
	_ "gitee.com/lllgo/opsctl/pkg/cmd/tmpl"
	"math/rand"
	"os"
	"runtime"
	"time"
)

func main() {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
			if _, ok := err.(error); ok {
				var buf [2 << 10]byte
				bytes := buf[:runtime.Stack(buf[:], true)]
				fmt.Println(string(bytes))
				os.Exit(1)
			}
		}
	}()

	rand.Seed(time.Now().UnixNano())
	if err := Execute(os.Args[1:]); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
